#include <string>
#include <vector>
#include <stack>

using namespace std;

class Solution
{
public:
    int evalRPN(vector<string> &tokens)
    {
        stack<int> nums;
        for (int i = 0; i < tokens.size(); ++i)
        {
            if (tokens[i] == "+" || tokens[i] == "-" || tokens[i] == "*" || tokens[i] == "/")
            {
                int num2 = nums.top();
                nums.pop();
                int num1 = nums.top();
                nums.pop();
                switch (tokens[i][0])
                {
                case '+':
                    nums.push(num1 + num2);
                    break;
                case '-':
                    nums.push(num1 - num2);
                    break;
                case '*':
                    nums.push(num1 * num2);
                    break;
                case '/':
                    nums.push(num1 / num2);
                    break;
                default:
                    break;
                }
            }
            else
            {
                nums.push(stoi(tokens[i]));
            }
        }
        return nums.top();
    }
};